package com.sam.book;

/**
 * 不相交集合类
 */
public class DisjSets {
    private int[] s;

    public DisjSets(int size) {
        s = new int[size];
        for (int i = 0; i < s.length; i++) {
            s[i] = -1;
        }
    }

    public void nuion(int root1, int root2) {
        s[root2] = root1;
    }

    public int find(int x) {
        if (s[x] < 0) {
            return x;
        } else {
            return find(s[x]);
        }

    }

    public static void main(String[] args) {
        System.out.println(String.format("ideas/%s/%s/%b/%d", "1", "2", true, System.currentTimeMillis()));
    }
}
